//
//  LWBrcodeViewController.m
//  1.28  weibo
//
//  Created by mac on 15/1/31.
//  Copyright (c) 2015年 mac. All rights reserved.
//

#import "LWBrcodeViewController.h"
#import "LWMyQrcodeViewController.h"

@interface LWBrcodeViewController ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topConstraint;

@property (nonatomic,strong) CADisplayLink *link;

- (IBAction)MyQrcodeClick:(UIButton *)sender;

@end

@implementation LWBrcodeViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.tabBarController.tabBar.tintColor = [UIColor orangeColor];
}

- (void)viewWillAppear:(BOOL)animated{
 
    [super viewWillAppear:animated];
    CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(updata)];
    [link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
    self.link = link;
}
//移除横线
- (void)viewWillDisAppear:(BOOL)animated{
    
    for (UIView *child in self.tabBarController.tabBar.subviews) {
        if ([child isKindOfClass:[UIImageView class]]) {
            [child removeFromSuperview];
        }
    }
    
    
}

- (void)viewWillDisappear:(BOOL)animated{

    [super viewWillDisappear:animated];
    [self.link invalidate];
    self.link = nil;
}

//当初始化Xib的时候调用
- (id)initWithCoder:(NSCoder *)aDecoder{

    self = [super initWithCoder:aDecoder];
    self.navigationItem.title = @"条形码";
    self.navigationController.title = @"条形码";
    self.navigationController.tabBarItem.image = [UIImage imageNamed:@"qrcode_tabbar_icon_barcode"];
    self.navigationController.tabBarItem.selectedImage = [UIImage imageNamed:@"qrcode_tabbar_icon_barcode_highlighted"];
    return self;
}

#pragma mark - 定时器监听的方法
- (void)updata{

    self.topConstraint.constant -= 5;
    if (self.topConstraint.constant <= -124) {
        self.topConstraint.constant = 124;
    }
}


- (IBAction)MyQrcodeClick:(UIButton *)sender {
    LWMyQrcodeViewController *me = [[LWMyQrcodeViewController alloc] init];
    [self.navigationController presentViewController:me animated:YES completion:nil];
}
@end
